package geez.widget;

import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.RadioButton;

import static geez.widget.Geez.withStyle;

public class GRadioButton extends RadioButton implements GClickable, GFocusable {

    public GRadioButton(String name) {
        super(name);
    }

    public GRadioButton(String name, String label) {
        super(name, label);
    }

    public GRadioButton(String name, String label, boolean asHtml) {
        super(name, label, asHtml);
    }

    public GRadioButton id(String id) {
        Geez.withNameAndId(this, id);
        return this;
    }

    public GRadioButton css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return this;
    }

    public GRadioButton show() {
        setVisible(true);
        return this;
    }

    public GRadioButton hide() {
        setVisible(false);
        return this;
    }

    public GRadioButton tabIndex(int index) {
        setTabIndex(index);
        return this;
    }

    public GRadioButton add(FocusHandler handler) {
        addFocusHandler(handler);
        return this;
    }

    public GRadioButton add(BlurHandler handler) {
        addBlurHandler(handler);
        return this;
    }

    public GRadioButton enable() {
        setEnabled(true);
        return this;
    }

    public GRadioButton disable() {
        setEnabled(false);
        return this;
    }

    public GRadioButton add(ClickHandler handler) {
        addClickHandler(handler);
        return this;
    }

    public GRadioButton focus() {
        setFocus(true);
        return this;
    }
}
